import pandas as pd
import matplotlib.pyplot as plt

from normalizing import normalizing

plt.rcParams['font.sans-serif'] = ['KaiTi', 'SimHei', 'FangSong']  # 汉字字体,优先使用楷体，如果找不到楷体，则使用黑体
plt.rcParams['font.size'] = 12  # 字体大小
plt.rcParams['axes.unicode_minus'] = False  # 正常显示负号
plt.figure(dpi=120)
markers = ['X', 'd', 'o', 's', 'p']


def myplot(xlsfile, sheetname, title) -> object:
    dataframe = pd.read_excel(xlsfile, sheet_name=sheetname)
    print('-----------原始数据-----------')
    print(dataframe.shape)
    print(dataframe)
    dataframe.drop(columns="时间", axis=1, inplace=True)
    dataframe.set_index([[2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019]],
                        inplace=True)
    normal_df = normalizing(dataframe)

    # 绘制折线图
    i = 0
    for column in list(normal_df.columns):
        col_data = normal_df[column]
        print('-----------' + column + '-----------')
        print(col_data)
        plt.title(title)
        plt.plot(col_data.index, col_data, label=column, marker=markers[i])
        i = i + 1
    plt.legend()
    plt.xlabel('时间-年度')
    plt.ylabel('归一化值')
    plt.show()
